//
//  EveryDaySendTableViewCell.m
//  NewMusic
//
//  Created by dllo on 15/11/20.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "EveryDaySendTableViewCell.h"

@interface EveryDaySendTableViewCell ()
//天
@property(nonatomic, retain) UILabel *titleOneLabel;
//月
@property(nonatomic, retain) UILabel *titleTowLabel;
@property(nonatomic, retain) UILabel *lineLabel;
//介绍
@property(nonatomic, retain) UILabel *descLabel;
@property(nonatomic, retain) UILabel *labelOne;
@property(nonatomic, retain) UILabel *labelTow;
@property(nonatomic, retain) UILabel *labelThree;
//图片
@property(nonatomic, retain) UIImageView *bigPicUrlImageView;

@property(nonatomic, retain) UILabel *showLabel;
@end

@implementation EveryDaySendTableViewCell
- (void)dealloc {
    [_theNewMVModel release];
    [_titleOneLabel release];
    [_titleTowLabel release];
    [_lineLabel release];
    [_descLabel release];
    [_labelOne release];
    [_labelTow release];
    [_labelThree release];
    [_bigPicUrlImageView release];
    [_showLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    //创建视图
    [self createSubView];
    }
    return self;
}
#pragma mark 创建视图
-(void)createSubView {
    //天
    self.titleOneLabel = [[UILabel alloc]init];
//    _titleOneLabel.backgroundColor = [UIColor redColor];
    _titleOneLabel.font = [UIFont systemFontOfSize:25];
    _titleOneLabel.textColor = [UIColor cyanColor];
    _titleOneLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_titleOneLabel];
    [_titleOneLabel release];
    //月
    self.titleTowLabel = [[UILabel alloc]init];
//    _titleTowLabel.backgroundColor = [UIColor blueColor];
    _titleTowLabel.textAlignment = NSTextAlignmentCenter;
    _titleTowLabel.textColor = [UIColor whiteColor];
    _titleTowLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_titleTowLabel];
    [_titleTowLabel release];
    
    self.lineLabel = [[UILabel alloc]init];
    _lineLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_lineLabel];
    [_lineLabel release];
    //介绍
    self.descLabel = [[UILabel alloc]init];
//    _descLabel.backgroundColor = [UIColor cyanColor];
    _descLabel.font = [UIFont systemFontOfSize:15];
    _descLabel.numberOfLines = 2;
    _descLabel.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_descLabel];
    [_descLabel release];
    
    self.labelOne = [[UILabel alloc]init];
    self.labelOne.textColor = [UIColor whiteColor];
    _labelOne.backgroundColor = [UIColor colorWithWhite:0.400 alpha:1.000];
    _labelOne.layer.masksToBounds = YES;
    _labelOne.layer.cornerRadius = 10;
    _labelOne.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_labelOne];
    [_labelOne release];
    
    self.labelTow = [[UILabel alloc]init];
    _labelTow.backgroundColor = [UIColor colorWithWhite:0.400 alpha:1.000];
    _labelTow.textColor = [UIColor whiteColor];
    _labelTow.layer.masksToBounds = YES;
    _labelTow.layer.cornerRadius = 10;
    _labelTow.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_labelTow];
    [_labelTow release];
    
    self.labelThree = [[UILabel alloc]init];
    _labelThree.backgroundColor = [UIColor colorWithWhite:0.400 alpha:1.000];
    _labelThree.textColor = [UIColor whiteColor];
    _labelThree.layer.masksToBounds = YES;
    _labelThree.layer.cornerRadius = 10;
    _labelThree.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_labelThree];
    [_labelThree release];
    //图片
    self.bigPicUrlImageView =[[UIImageView alloc]init];
//    _bigPicUrlImageView.backgroundColor =[UIColor purpleColor];
    [self.contentView addSubview:_bigPicUrlImageView];
    [_bigPicUrlImageView release];
    
    self.showLabel =[[UILabel alloc]init];
    _showLabel.backgroundColor = [UIColor blackColor];
    _showLabel.alpha = 0.5;
    _showLabel.layer.masksToBounds = YES;
    _showLabel.layer.cornerRadius = 25;
    [_bigPicUrlImageView addSubview:_showLabel];
    [_showLabel release];
    
    //播放button
    self.showButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    _showButton.backgroundColor =[UIColor whiteColor];
    [_showButton setImage:[UIImage imageNamed:@"icon_bofang5"] forState:UIControlStateNormal];
    [self.contentView addSubview:_showButton];
}
#pragma mark 设置大小
-(void)layoutSubviews {
    [super layoutSubviews];
    //天
    _titleOneLabel.frame = CGRectMake(10, 5, 40, self.height / 7 );
    _lineLabel.frame = CGRectMake(_titleOneLabel.x, _titleOneLabel.bottomY, _titleOneLabel.width, 1);
    //月
    _titleTowLabel.frame = CGRectMake(_titleOneLabel.x, _lineLabel.bottomY, _lineLabel.width, self.height / 10);
    //介绍
    _descLabel.frame = CGRectMake(_titleOneLabel.rightX + 5, _titleOneLabel.y, self.width - _titleOneLabel.rightX - 20, _titleOneLabel.height);
    //图片
    _bigPicUrlImageView.frame = CGRectMake(_titleTowLabel.x, _titleTowLabel.bottomY + 5, self.width - _titleTowLabel.x * 2, self.height - _titleTowLabel.bottomY - 20);
    //播放buttton
    _showLabel.frame = CGRectMake((_bigPicUrlImageView.width - 50) / 2, (_bigPicUrlImageView.height - 50) / 2, 50, 50);
    _showButton.frame = CGRectMake((self.width - 40) / 2 + 5, (_bigPicUrlImageView.height - 40) / 2 + _bigPicUrlImageView.topY, 35, 40);
    if (self.theNewMVModel.tagArray.count != 0) {
        _labelOne.frame = CGRectMake(_descLabel.x, _descLabel.bottomY + 5, 60, _titleTowLabel.height - 10);
        _labelTow.frame = CGRectMake(_labelOne.rightX + 10, _labelOne.y, _labelOne.width, _labelOne.height);
        _labelThree.frame = CGRectMake(_labelTow.rightX +  10, _labelTow.y, _labelTow.width, _labelTow.height);
    }
}
#pragma mark重写theNewMVModel的setter方法
- (void)setTheNewMVModel:(TheNewMVModel *)theNewMVModel {
    if (_theNewMVModel != theNewMVModel) {
        [_theNewMVModel release];
        _theNewMVModel = [theNewMVModel retain];
    }
    _titleOneLabel.text = [theNewMVModel.title substringToIndex:2];
    _titleTowLabel.text = [theNewMVModel.title substringFromIndex:3];
    _descLabel.text = theNewMVModel.desc;
    [_bigPicUrlImageView sd_setImageWithURL:[NSURL URLWithString:theNewMVModel.bigPicUrl]];
    _labelOne.text = [theNewMVModel.tagArray[0] valueForKey:@"tagName"];
    _labelTow.text = [theNewMVModel.tagArray[1] valueForKey:@"tagName"];
    _labelThree.text = [theNewMVModel.tagArray[2] valueForKey:@"tagName"];
    
}
#pragma mark重写showTag的setter方法
- (void)setShowTag:(BOOL)showTag {
    if (_showTag != showTag) {
        _showTag = showTag;
    }
    if (_showTag == NO) {
        _labelOne.frame = CGRectMake(0, 0, 0, 0);
        _labelTow.frame = CGRectMake(0, 0, 0, 0);
        _labelThree.frame = CGRectMake(0, 0, 0, 0);
    }
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
